class_name BoarStatusBase extends StatusBase
   
# 由父节点 status machine指定
var actor:BoarEnemy

func find_player()->bool:
	if not actor.player_checker.is_colliding():
		return false
	var is_player = actor.player_checker.get_collider() is Player
	return is_player

func find_wall()->bool:
	return actor.wall_checker.is_colliding()

func find_floor()->bool:
	return actor.floor_checker.is_colliding()

func common_velocity(delta:float, rate:float)->void:
	actor.velocity.y += blackboard.gravity * delta
	if rate == 0.0:
		actor.velocity.x = 0.0
		return
		
	if actor.is_on_floor():
		actor.velocity.x = move_toward(actor.velocity.x, blackboard.max_speed * blackboard.direction * rate , actor.max_speed / 0.2 * delta)
	else:
		actor.velocity.x = move_toward(actor.velocity.x, 0 , blackboard.max_speed / 0.2 * delta)
	
# 呆着
func idle_velocity(delta:float)->void:
	common_velocity(delta,0.0)
	
func turn_direction():
	actor.face_direction(blackboard.direction*-1)
	
func is_weak() -> bool:
	return blackboard.get_health() == 1
